<%@ Page Title="My Setups" Language="C#" MasterPageFile="~/MasterPage.master"
   AutoEventWireup="true" CodeFile="MySetups.aspx.cs" Inherits="MySetups" %>

<%-- Custom made page for screwturn wiki --%>
<asp:Content ID="Content1" ContentPlaceHolderID="CphMaster" runat="Server">
   <h1 class="pagetitlesystem">
      <asp:Literal ID="lblTitle" runat="server" meta:resourcekey="lblTitleResource1"
         Text="My Setups" />
   </h1>
   <asp:Panel runat="server">
      <asp:SqlDataSource ID="UserSetupsSQLDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:NMRUserDataConnectionString %>"
         SelectCommand="
               SELECT setups.id AS Id, 
                      setups.date AS Date, 
                      setups.[content] AS [Content], 
                      setups.remark AS Remark, 
                      setups.name AS Name,
                      setups.experimentid AS ExpID,
                      setups.experimentname AS ExpName,
                      setups.sampleid AS SampleID,
                      setups.samplename AS SampleName,
                      setups.spectrometerid AS SpecID,
                      setups.spectrometername AS SpecName 
               FROM relation_setups_to_users 
                  INNER JOIN setups ON relation_setups_to_users.setupid = setups.id 
               WHERE (relation_setups_to_users.username = @username) ORDER BY Date DESC">
         <SelectParameters>
            <asp:Parameter DefaultValue="none" Name="username" />
         </SelectParameters>
      </asp:SqlDataSource>
      <asp:GridView ID="SetupsTableGridView" runat="server" AllowPaging="True"
         AllowSorting="True" AutoGenerateColumns="False" BackColor="White" BorderColor="#E7E7FF"
         BorderStyle="None" BorderWidth="1px" CellPadding="3" DataSourceID="UserSetupsSQLDataSource"
         GridLines="Horizontal" Width="100%" EmptyDataText="You did not yet setup any experiment."
         PageSize="20">
         <RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" />
         <Columns>
            <asp:TemplateField HeaderText="Name" SortExpression="Name">
               <ItemTemplate>
                  <asp:HyperLink runat="server" Text='<%# Eval("Name") %>' NavigateUrl='<%# Eval("Id", "~/GetMacro.aspx?SetupID={0}") %>'
                     ID="hlDownloadMacro"></asp:HyperLink>
               </ItemTemplate>
               <ItemStyle Width="400px" VerticalAlign="Top" />
            </asp:TemplateField>
            <asp:BoundField DataField="Remark" HeaderText="Remark" SortExpression="Remark">
               <ItemStyle VerticalAlign="Top" />
            </asp:BoundField>
            <asp:TemplateField HeaderText="Experiment" SortExpression="ExpName">
               <ItemTemplate>
                  <asp:HyperLink runat="server" Text='<%# Eval("ExpName") %>' NavigateUrl='<%# Eval("ExpID", "~/Experiment_id_{0}.ashx") %>'></asp:HyperLink>
               </ItemTemplate>
               <ItemStyle Width="100px" VerticalAlign="Top" />
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Sample" SortExpression="SampleName">
               <ItemTemplate>
                  <asp:HyperLink ID="HyperLink1" runat="server" Text='<%# Eval("SampleName") %>' NavigateUrl='<%# Eval("SampleID", "~/MySamples.aspx?SampleID={0}") %>'></asp:HyperLink>
               </ItemTemplate>
               <ItemStyle Width="100px" VerticalAlign="Top" />
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Spectrometer" SortExpression="SpecName">
               <ItemTemplate>
                  <asp:HyperLink ID="HyperLink1" runat="server" Text='<%# Eval("SpecName") %>' NavigateUrl='<%# Eval("SpecID", "~/MySpectrometers.aspx?SpecID={0}") %>'></asp:HyperLink>
               </ItemTemplate>
               <ItemStyle Width="100px" VerticalAlign="Top" />
            </asp:TemplateField>
            <asp:BoundField DataField="Date" DataFormatString="{0:d}" HeaderText="Date"
               SortExpression="Date">
               <ItemStyle HorizontalAlign="Left" VerticalAlign="Top" Width="100px" />
            </asp:BoundField>
            <asp:BoundField DataField="Content" HeaderText="Content" SortExpression="Content"
               Visible="False" />
            <asp:BoundField DataField="Id" HeaderText="Id" SortExpression="Id" Visible="false" />
         </Columns>
         <FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />
         <PagerStyle BackColor="#4A3C8C" ForeColor="#4A3C8C" HorizontalAlign="Right" />
         <SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" />
         <HeaderStyle HorizontalAlign="Left" BackColor="#4A3C8C" Font-Bold="True"
            ForeColor="#F7F7F7" />
         <AlternatingRowStyle BackColor="#F7F7F7" />
      </asp:GridView>
   </asp:Panel>
</asp:Content>
